//
//  main.m
//  MacConsole
//
//  Created by MacVM on 2023/12/30.
//

#import <Foundation/Foundation.h>

int _1main(int argc, const char * argv[]) {
    @autoreleasepool {
        // insert code here...
        NSDate * now = [NSDate date];
        double dateInterval = [now timeIntervalSince1970];
        double dateNow = [now timeIntervalSinceNow];
        NSLog(@"Hello, World! now:%@\nfrom 1970: %f - %f", now, dateInterval, dateNow);
        
        NSLog(@"tomorrow of now:%@", [now dateByAddingTimeInterval:3600*24]);
        
        NSCalendar * calendar = NULL; // [NSCalendar currentCalendar];
        NSLog(@"date of today:%lu", (unsigned long)[calendar ordinalityOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:now]);
        
//        NSHost* host = [NSHost currentHost];
//        NSLog(@"Mac:%@, IP:%@", [host localizedName], [host addresses]);
        
        // 创建指定日期，时间
        NSDateComponents * dateCom = [[NSDateComponents alloc]init];
        [dateCom setYear:2023];
        [dateCom setMonth:12];
        [dateCom setDay:31];
        [dateCom setHour:23];
        [dateCom setMinute:59];
        [dateCom setSecond:59];
        
        NSDate * dateLastSecond = [[[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian] dateFromComponents:dateCom];
        
        NSLog(@"LastSecond of 2023:%@", dateLastSecond);
        
        printf("print with printf. %s\n", "print");
    }
    return 0;
}
